﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Utilities;

namespace SceneManager.Processors
{
    public class ScreenProcessor : TextureProcessor
    {
        //public new DynamicDictionary<string, Texture2D> Inputs { get; set; }
        private SpriteBatch spriteBatch;

        public ScreenProcessor(Game game) : base(game)
        {
            //Inputs = new DynamicDictionary<string, Texture2D>();
            Inputs.Add("Input", null);
            Inputs.Add("Input1", null);
            Inputs.Add("Input2", null);
            Inputs.Add("Input3", null);
            Inputs.Add("Input4", null);
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
        }

        public override void Process(Camera camera, GameTime gameTime)
        {
#if DEBUG
            stopwatch.Restart();
#endif

            Game.GraphicsDevice.SetRenderTarget(null);
            Game.GraphicsDevice.BlendState = BlendState.AlphaBlend;
            Game.GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise);
            foreach (KeyValuePair<string, Texture2D> kvp in Inputs)
                if (kvp.Value != null)
                    spriteBatch.Draw(kvp.Value, Vector2.Zero, Color.White);
            spriteBatch.End();

#if DEBUG
            processTimes.Enqueue((int)stopwatch.ElapsedTicks);
            while (processTimes.Count > 60)
                processTimes.Dequeue();
#endif
        }
    }
}
